﻿using UnityEditor;
using UnityEditor.UI;
using UnityEngine;

[CustomEditor(typeof(ImagePolygon))]
public class ImagePolygonEditor : ImageEditor
{
    ImagePolygon circleImage;
    SerializedProperty points;

    protected override void OnEnable()
    {
        base.OnEnable();

        circleImage = (ImagePolygon)target;

        points = serializedObject.FindProperty("points");
    }

    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        circleImage.texScale = EditorGUILayout.FloatField("Tex Scale", circleImage.texScale);
        if (circleImage.texScale < 0) circleImage.texScale = 0;

        EditorGUILayout.PropertyField(points);

        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(target);
            circleImage.SetAllDirty();
        }
    }
}